package dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import dao.IStorageDAO;

import entity.Storage;

public class IStorageDAOImpl extends HibernateDaoSupport implements IStorageDAO{
	String hql=null;
	@SuppressWarnings("unchecked")
	@Override
	public ArrayList<Storage> findAllStorage() throws Exception {
		hql = "from Storage";
		//sessionFactory--session --Query.setString()
		return this.getHibernateTemplate().execute(new HibernateCallback(){

			@Override
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				Query query = session.createQuery(hql);
//				query.setString(0, storage.getStkMemo());
//				query.setString(1, storage.getStkWare());
				
				return query.list();
			}
			
		});
	}

}
